<template>
  <el-card style="height: 500px" size="small" >
    <el-descriptions title="用户信息" :column="1" style="margin-left: 200px;width: 400px" border >
      <el-descriptions-item label="用户名" label-class-name="my-label" content-class-name="my-content" >{{userinfo.userName}}</el-descriptions-item>
      <el-descriptions-item label="昵称" >{{userinfo.nickName}}</el-descriptions-item>
      <el-descriptions-item label="创建时间" >{{userinfo.createTime}}</el-descriptions-item>
      <el-descriptions-item label="手机号" >{{userinfo.phone}}</el-descriptions-item>
      <el-descriptions-item label="会员名称">
        <el-tag size="small">{{userinfo.roleName}}</el-tag>
      </el-descriptions-item>
    </el-descriptions>
  </el-card>
</template>
<script>
export default {
  data() {
    return {
      userinfo: {}
    };
  },
  created(){
    let url ='http://localhost:8080/v1/users/details/'+localStorage.getItem("id");
    console.log('url ='+url);
    this.axios
        .create({'headers': {'Authorization': localStorage.getItem('localJwt')}})
        .get(url).then((response)=>{
      let jsonResult=response.data;
      if(jsonResult.code==1) {
        this.userinfo=jsonResult.data;
      }else if(localStorage.getItem("id")){
        this.$message.error("您还不是管理员,无权登录")
        setTimeout(()=>{
          history.back()
        },1000)


      }else{
        this.$message.error("请先登录")
        setTimeout(()=>{
          history.back()
        },1000)
      }
    })
  }
}
</script>

<style scoped>

</style>